﻿using SqlSugar.IOC;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Cl.Entity.BaseEntity;

namespace Cl.Repository
{
    public class CLBaseRepository<T> : SimpleClient<T> where T : class, new()
    {
        public CLBaseRepository(ISqlSugarClient? context = null) : base(context)
        {
            Context = DbScoped.SugarScope;
        }

        /// <summary>
        /// 开启事务
        /// </summary>
        public void BeginTran()
        {
            AsTenant().BeginTran();
        }

        /// <summary>
        /// 提交事务
        /// </summary>
        public void CommitTran()
        {
            AsTenant().CommitTran();
        }

        /// <summary>
        /// 回滚事务
        /// </summary>
        public void RollbackTran()
        {
            AsTenant().RollbackTran();
        }
    }
}
